﻿using System;
using System.IO;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;

using CE.AreaCountry;
using CE.User;
using CE.Global;
using CE.Database;
using CE.Provider;
using CE.TravelInsurance;
using CE.Company;
using CE.Mail;

public partial class travel_travel_result_detail : System.Web.UI.Page
{
    //protected void Page_Init(object sender, EventArgs e)
    //{
    //    GetResultDetails();
    //}

    protected void Page_Load(object sender, EventArgs e)
    {
        if (Request.QueryString["taid"] == null || Session[General.TAId] == null)
        {
            Response.Redirect("travel-result.aspx");
        }

        if (!Page.IsPostBack)
        {
            if (Session[General.TAId] != null)
            {
                if (Session["PlanType"] != null)
                {
                    inputPlanType.Value = Session["PlanType"].ToString();
                }
                LoadSummary();

                GetResultDetails();
            }


            imgEmailQuote.Attributes.Add("onclick", "return confirm('Are you sure you want to send this quote?');");
        }
    }

    protected void LoadSummary()
    {
        Int64 TAId = 0;

        TAApplicantSearchDB _taapplicantsearchdb = new TAApplicantSearchDB();
        TAApplicantSearch _taapplicantsearch = new TAApplicantSearch();

        if (Session[General.TAId] != null)
            TAId = Convert.ToInt64(Session[General.TAId]);

        _taapplicantsearch = _taapplicantsearchdb.GetTAApplicantSearchItem(TAId);

        if (_taapplicantsearch != null)
        {

            lblTripType.Text = GetCoverage(_taapplicantsearch.TripType.ToString());
            lblPolicy.Text = GetPolicy(_taapplicantsearch.PlanType.ToString());
            lblTravelDate.Text = String.Format("{0:dd/MM/yyyy} To {1:dd/MM/yyyy}", _taapplicantsearch.StartDate, _taapplicantsearch.EndDate);
            lblTravellers.Text = (_taapplicantsearch.NoofChilds + _taapplicantsearch.NoofAdults).ToString();

            inputNoOfAdult.Value = _taapplicantsearch.NoofAdults.ToString();

            if (_taapplicantsearch.AreaID != 0)
                lblDestination.Text = GetAreaName(_taapplicantsearch.AreaID);
            else
                lblDestination.Text = GetCountryName(_taapplicantsearch.CountryID);

            lblCoverage.Text = GetCoverage(_taapplicantsearch.CoverageLevel);

            lblQuoteDate.Text = CE.Global.General.GetUTCDateTime().ToString("dd/MMM/yyyy");
        }
    }

    protected string GetAreaName(Int64 areaid)
    {
        string Area = "";

        AreaInfo _areainfo = new AreaInfo();
        AreaInfoDB _areainfodb = new AreaInfoDB();

        _areainfo = _areainfodb.GetAreaInfo(areaid);

        Area = _areainfo.Description;

        return Area;

    }

    protected string GetCountryName(Int64 countryid)
    {
        string Country = "";

        CountryInfo _countryinfo = new CountryInfo();
        CountryInfoDB _countryinfodb = new CountryInfoDB();

        _countryinfo = _countryinfodb.GetCountryInfo(countryid);

        Country = _countryinfo.Description;

        return Country;

    }

    protected string GetPolicy(string covertype)
    {
        string policy = "family";

        if (covertype == "IND")
        {
            policy = "Individual";
        }
        else if (covertype == "INS")
        {
            policy = "Individual + Spouse";
        }
        else if (covertype == "INC")
        {
            policy = "Individual + Child";
        }
        else if (covertype == "FML")
        {
            policy = "Family";
        }

        return policy;
    }

    protected string GetCoverage(string coverage)
    {
        string cover = "Single Trip";

        if (coverage == "A")
            cover = "Annual Multi-trip";

        return cover;
    }

    private void GetResultDetails()
    {
        string qs_travelselected = "";

        if (Request.QueryString["taid"] != null)
        {
            qs_travelselected = Request.QueryString["taid"].ToString();
        }

        if (qs_travelselected != "" && Session[General.TAId] != null)
        {
            if (Cache["Mobile.TAResultsQuotes" + Session[General.TAId].ToString()] != null)
            {
                DataView dv = new DataView((DataTable)Cache["Mobile.TAResultsQuotes" + Session[General.TAId].ToString()]);

                string TAInsID = qs_travelselected;

                dv.RowFilter = " TAInsID in (" + TAInsID + ")";
                DataTable dtFiltered = dv.ToTable();

                if (dtFiltered.Rows.Count > 0)
                {
                    int rowCount = dtFiltered.Rows.Count;

                    lblTAResultID.Text = TAInsID;

                    for (int iRows = 0; iRows < rowCount; iRows++)
                    {                   
                        string _providercompanyid = dtFiltered.Rows[iRows]["ProviderCompanyId"].ToString();

                        string convertno = General.GetRefNumber(Convert.ToInt64(Session[General.TAId].ToString()));
                        lblRefNo.Text = "TIL" + convertno;

                        if (_providercompanyid == "23")
                            lblRefNo.Text = "TIH" + convertno;
                        else if (_providercompanyid == "24")
                            lblRefNo.Text = "TIR" + convertno;
                        else if (_providercompanyid == "29")
                            lblRefNo.Text = "TIL" + convertno;
                        else if (_providercompanyid == "30")
                            lblRefNo.Text = "TIE" + convertno;
                        else if (_providercompanyid == "31")
                            lblRefNo.Text = "TIC" + convertno;
                        else if (_providercompanyid == "34")
                            lblRefNo.Text = "TICH" + convertno;
                        else if (_providercompanyid == "35")
                            lblRefNo.Text = "TIEQ" + convertno;
                        else if (_providercompanyid == "36")
                            lblRefNo.Text = "TIA" + convertno;
                        else if (_providercompanyid == "37")
                            lblRefNo.Text = "TI1C" + convertno;
                        else if (_providercompanyid == "38")
                            lblRefNo.Text = "TID" + convertno;

                        lblInsurer.Text = dtFiltered.Rows[iRows]["insurername"].ToString();

                        string companylogourl = dtFiltered.Rows[iRows]["CompanyLogoServerUrl"].ToString();

                        if (dtFiltered.Rows[iRows]["CompanyLogoServerUrl"].ToString().Substring(0, 1) == "~")
                        {
                            companylogourl = dtFiltered.Rows[iRows]["CompanyLogoServerUrl"].ToString().Remove(0, 1);
                        }

                       
                        imgInsurer.ImageUrl = "http://www.comparexpress.com" + companylogourl;
                        //imgInsurer.Width = 120;

                        //hlnkProvider.NavigateUrl = "provider_detail.aspx?pid=" + _providercompanyid;

                        //PlanName
                        lblPackage.Text = "<strong>" + dtFiltered.Rows[iRows]["PlanName"].ToString() + "</strong>";

                        //Premium
                        string annualprice = String.Format("${0:0,0.00}", Convert.ToSingle(dtFiltered.Rows[iRows]["annualpremium"].ToString()));
                        lblPrice.Text = annualprice;

                        string _planname = dtFiltered.Rows[iRows]["PlanName"].ToString();
                        string premiumamt = dtFiltered.Rows[iRows]["annualpremium"].ToString();
                        Int64 _resultId = int.Parse(qs_travelselected);
                        Int64 _taid = Convert.ToInt64(Session[General.TAId].ToString());
                        Int64 _userId = 0;

                        if (Session[General.UserId] != null)
                            _userId = Convert.ToInt64(Session[General.UserId].ToString());
                        else if (Session[General.TAPersonnelId] != null)
                            _userId = Convert.ToInt64(Session[General.TAPersonnelId].ToString());
                        
                        string _fullname = "";
                        string _mobile = "";
                        string _email = "";
                        string _nric = "";
                        string _title = "";
                        string _ctname2 = "";

                        if (Session[General.TAUserName] != null)
                            _fullname = Session[General.TAUserName].ToString();

                        if (Session[General.TAPhoneNo] != null)
                            _mobile = Session[General.TAPhoneNo].ToString();

                        if (Session[General.TAEmail] != null)
                            _email = Session[General.TAEmail].ToString();

                        if (Session["Mobile.NRIC"] != null)
                            _nric = Session["Mobile.NRIC"].ToString();

                        if (Session["Mobile.SpouseName"] != null)
                            _ctname2 = Session["Mobile.SpouseName"].ToString();


                        ibtBuyNow.OnClientClick = "javascript:void(0);ManageRedirect('" + _providercompanyid + "', '" + _resultId + "', " +
                                    "'" + premiumamt + "', '" + _userId + "','" + _taid + "', '" + _planname + "', '" + _fullname + "', " +
                                    "'" + _mobile + "', '" + _email + "', '" + _nric + "', '" + _title + "', '" + _ctname2 + "');return false;";

                        //Personal Accident adult
                        if (Convert.ToInt32(dtFiltered.Rows[iRows]["DTPD_LessYr70"].ToString()) == 0)
                        {
                            imgPAadult.Visible = true;
                            imgPAadult.ImageUrl = "http://www.comparexpress.com/images/icon/X.png";
                        }
                        else
                        {
                            lblPAadult.Text = String.Format("${0:#,0}", Convert.ToInt32(dtFiltered.Rows[iRows]["DTPD_LessYr70"].ToString()));
                        }

                        //Personal Accident >70
                        if (Convert.ToInt32(dtFiltered.Rows[iRows]["DTPD_LessYr70"].ToString()) == 0)
                        {
                            imgPAsenior.Visible = true;
                            imgPAsenior.ImageUrl = "http://www.comparexpress.com/images/icon/X.png";
                        }
                        else
                        {
                            lblPAsenior.Text = String.Format("${0:#,0}", Convert.ToInt32(dtFiltered.Rows[iRows]["DTPD_AboveYr70"].ToString()));
                        }

                        //Double Indemnity adult
                        if (_providercompanyid == "34")
                        {
                            hlnkDIadult.Visible = true;
                            hlnkDIadult.ImageUrl = "http://www.comparexpress.com/images/icon/pdf.png";
                            hlnkDIadult.NavigateUrl = "http://www.comparexpress.com/policy_docs/ChinaTaiping/Coverage.pdf";
                            hlnkDIadult.Target = "_blank";
                        }
                        else if (Convert.ToInt32(dtFiltered.Rows[iRows]["DIPC_LessYr70"].ToString()) == 0)
                        {
                            imgDIadult.Visible = true;
                            imgDIadult.ImageUrl = "http://www.comparexpress.com/images/icon/X.png";
                        }
                        else
                        {
                            lblDIadult.Text = String.Format("${0:#,0}", Convert.ToInt32(dtFiltered.Rows[iRows]["DIPC_LessYr70"].ToString()));
                        }

                        //Double Indemnity  >70
                        if (_providercompanyid == "34")
                        {
                            hlnkDIsenior.Visible = true;
                            hlnkDIsenior.ImageUrl = "http://www.comparexpress.com/images/icon/pdf.png";
                            hlnkDIsenior.NavigateUrl = "http://www.comparexpress.com/policy_docs/ChinaTaiping/Coverage.pdf";
                            hlnkDIsenior.Target = "_blank";
                        }
                        else if (Convert.ToInt32(dtFiltered.Rows[iRows]["DIPC_AboveYr70"].ToString()) == 0)
                        {
                            imgDIsenior.Visible = true;
                            imgDIsenior.ImageUrl = "http://www.comparexpress.com/images/icon/X.png";
                        }
                        else
                        {
                            lblDIsenior.Text = String.Format("${0:#,0}", Convert.ToInt32(dtFiltered.Rows[iRows]["DIPC_AboveYr70"].ToString()));
                        }

                        //MEdical Expense adult
                        if (_providercompanyid == "34")
                        {
                            hlnkMedExpadult.Visible = true;
                            hlnkMedExpadult.ImageUrl = "http://www.comparexpress.com/images/icon/pdf.png";
                            hlnkMedExpadult.NavigateUrl = "http://www.comparexpress.com/policy_docs/ChinaTaiping/Coverage.pdf";
                            hlnkMedExpadult.Target = "_blank";
                        }
                        else if (Convert.ToInt32(dtFiltered.Rows[iRows]["MedExp_LessYr70"].ToString()) == 0)
                        {
                            imgMedExpadult.Visible = true;
                            imgMedExpadult.ImageUrl = "http://www.comparexpress.com/images/icon/X.png";
                        }
                        else
                        {
                            lblMedExpadult.Text = String.Format("${0:#,0}", Convert.ToInt32(dtFiltered.Rows[iRows]["MedExp_LessYr70"].ToString()));

                            if (_providercompanyid == "38")
                            {
                                lblMedExpadult.Text = lblMedExpadult.Text + "<br/>TCM: $300";
                            }
                            else if (_providercompanyid == "36")
                            {
                                lblMedExpadult.Text = lblMedExpadult.Text + "<br/>TCM: $750";
                            }
                        }

                        //MEdical Expense senior
                        if (_providercompanyid == "34")
                        {
                            hlnkMedExpsenior.Visible = true;
                            hlnkMedExpsenior.ImageUrl = "http://www.comparexpress.com/images/icon/pdf.png";
                            hlnkMedExpsenior.NavigateUrl = "http://www.comparexpress.com/policy_docs/ChinaTaiping/Coverage.pdf";
                            hlnkMedExpsenior.Target = "_blank";
                        }
                        else if (Convert.ToInt32(dtFiltered.Rows[iRows]["MedExp_AboveYr70"].ToString()) == 0)
                        {
                            imgMedExpsenior.Visible = true;
                            imgMedExpsenior.ImageUrl = "http://www.comparexpress.com/images/icon/X.png";
                        }
                        else
                        {
                            lblMedExpsenior.Text = String.Format("${0:#,0}", Convert.ToInt32(dtFiltered.Rows[iRows]["MedExp_AboveYr70"].ToString()));

                            if (_providercompanyid == "38")
                            {
                                lblMedExpsenior.Text = lblMedExpsenior.Text + "<br/>TCM: $300";
                            }
                            else if (_providercompanyid == "36")
                            {
                                lblMedExpsenior.Text = lblMedExpsenior.Text + "<br/>TCM: $750";
                            }
                        }

                        //Emergency Medical Evacuation
                        if (_providercompanyid == "34")
                        {
                            hlnkEmMedEvac.Visible = true;
                            hlnkEmMedEvac.ImageUrl = "http://www.comparexpress.com/images/icon/pdf.png";
                            hlnkEmMedEvac.NavigateUrl = "http://www.comparexpress.com/policy_docs/ChinaTaiping/Coverage.pdf";
                            hlnkEmMedEvac.Target = "_blank";
                        }
                        else if (_providercompanyid == "23")
                        {
                            lblEmMedEvac.Text = "<font color=Red>*as charged</font>";
                        }
                        else if (_providercompanyid == "24")
                        {
                            lblEmMedEvac.Text = "<font color=Red>Unlimited</font>";
                        }
                        else if (Convert.ToInt32(dtFiltered.Rows[iRows]["EmMedEval"].ToString()) == 0)
                        {
                            imgEmMedEvac.Visible = true;
                            imgEmMedEvac.ImageUrl = "http://www.comparexpress.com/images/icon/X.png";
                        }
                        else
                        {
                            lblEmMedEvac.Text = String.Format("${0:#,0}", Convert.ToInt32(dtFiltered.Rows[iRows]["EmMedEval"].ToString()));

                            if (_providercompanyid == "38")
                            {
                                lblEmMedEvac.Text = lblEmMedEvac.Text + "<br/>(combined cover with Repatriation & Funeral Expense)";
                            }
                        }

                        //Repatriation & Funeral Expenses
                        if (_providercompanyid == "34")
                        {
                            hlnkRepatriation.Visible = true;
                            hlnkRepatriation.ImageUrl = "http://www.comparexpress.com/images/icon/pdf.png";
                            hlnkRepatriation.NavigateUrl = "http://www.comparexpress.com/policy_docs/ChinaTaiping/Coverage.pdf";
                            hlnkRepatriation.Target = "_blank";
                        }
                        else
                        {
                            if (dtFiltered.Rows[iRows]["info5"].ToString() == "True")
                            {
                                lblRepatriation.Text = "<font color=Red>*as charged</font>";

                                if (_providercompanyid == "36" || _providercompanyid == "24")
                                {
                                    lblRepatriation.Text = "<font color=Red>Unlimited</font>";
                                }

                                if (_providercompanyid == "23")
                                {
                                    lblRepatriation.Text += "<br/>($30,000 for repatriation)";
                                }

                            }
                            else if (Convert.ToInt32(dtFiltered.Rows[iRows]["BCR"].ToString()) == 0)
                            {
                                imgRepatriation.Visible = true;
                                imgRepatriation.ImageUrl = "http://www.comparexpress.com/images/icon/X.png";
                            }
                            else
                            {
                                lblRepatriation.Text = String.Format("${0:#,0}", Convert.ToInt32(dtFiltered.Rows[iRows]["BCR"].ToString()));

                                if (_providercompanyid == "38")
                                {
                                    lblRepatriation.Text = lblRepatriation.Text + "<br/>(combined cover with Emergency Medical Evacuation)";
                                }
                            }
                        }

                        //Hospital Income
                        if (_providercompanyid == "34")
                        {
                            hlnkHospitalInc.Visible = true;
                            hlnkHospitalInc.ImageUrl = "http://www.comparexpress.com/images/icon/pdf.png";
                            hlnkHospitalInc.NavigateUrl = "http://www.comparexpress.com/policy_docs/ChinaTaiping/Coverage.pdf";
                            hlnkHospitalInc.Target = "_blank";
                        }
                        else if (_providercompanyid == "24") //RSA
                        {
                            lblHospitalInc.Text = String.Format("{0:c0}", int.Parse(dtFiltered.Rows[iRows]["NInfo4"].ToString()));
                        }
                        else
                        {
                            float _fHospIncome = 0;
                            if (dtFiltered.Rows[iRows]["HospIncome"].ToString() != "")
                            {
                                _fHospIncome = Convert.ToSingle(dtFiltered.Rows[iRows]["HospIncome"].ToString());
                            }

                            if (_fHospIncome > 0.0f)
                            {
                                string _HospIncome = String.Format("{0:c0}", _fHospIncome);
                                lblHospitalInc.Text = _HospIncome + "/day <br/> max " + String.Format("{0:c0}", int.Parse(dtFiltered.Rows[iRows]["NInfo4"].ToString()));

                            }
                            else
                            {
                                imgHospitalInc.Visible = true;
                                imgHospitalInc.ImageUrl = "http://www.comparexpress.com/images/icon/X.png";
                            }
                        }


                        //Pregnancy
                        if (_providercompanyid == "34")
                        {
                            hlnkPregnancy.Visible = true;
                            hlnkPregnancy.ImageUrl = "http://www.comparexpress.com/images/icon/pdf.png";
                            hlnkPregnancy.NavigateUrl = "http://www.comparexpress.com/policy_docs/ChinaTaiping/Coverage.pdf";
                            hlnkPregnancy.Target = "_blank";
                        }
                        else
                        {
                            float _fPregnancy = 0;
                            if (dtFiltered.Rows[iRows]["NInfo3"].ToString() != "")
                            {
                                _fPregnancy = Convert.ToSingle(dtFiltered.Rows[iRows]["NInfo3"].ToString());
                            }

                            if (_fPregnancy > 0.0f)
                            {
                                string _Pregnancy = String.Format("{0:c0}", _fPregnancy);

                                if (_providercompanyid == "38")
                                {
                                   lblPregnancy.Text = "Covered under Medical Expenses (adult)";
                                }
                                else
                                {
                                    lblPregnancy.Text = _Pregnancy;
                                }

                            }
                            else
                            {
                                imgPregnancy.Visible = true;
                                imgPregnancy.ImageUrl = "http://www.comparexpress.com/images/icon/X.png";
                            }
                        }

                        //Overseas Compa Visit                        
                        if (_providercompanyid == "34")
                        {
                            hlnkOCV.Visible = true;
                            hlnkOCV.ImageUrl = "http://www.comparexpress.com/images/icon/pdf.png";
                            hlnkOCV.NavigateUrl = "http://www.comparexpress.com/policy_docs/ChinaTaiping/Coverage.pdf";
                            hlnkOCV.Target = "_blank";
                        }
                        else
                        {
                            float _fCompaVisit = 0;
                            if (dtFiltered.Rows[iRows]["CompassVisit"].ToString() != "")
                            {
                                _fCompaVisit = Convert.ToSingle(dtFiltered.Rows[iRows]["CompassVisit"].ToString());
                            }

                            if (_fCompaVisit > 0.0f)
                            {
                                string _CompaVisit = String.Format("{0:c0}", _fCompaVisit);
                                lblOCV.Text = _CompaVisit;

                            }
                            else
                            {
                                imgOCV.Visible = true;
                                imgOCV.ImageUrl = "http://www.comparexpress.com/images/icon/X.png";
                            }
                        }
                        
                        //Child Guard
                        if (_providercompanyid == "34")
                        {
                            hlnkChildGuard.Visible = true;
                            hlnkChildGuard.ImageUrl = "http://www.comparexpress.com/images/icon/pdf.png";
                            hlnkChildGuard.NavigateUrl = "http://www.comparexpress.com/policy_docs/ChinaTaiping/Coverage.pdf";
                            hlnkChildGuard.Target = "_blank";
                        }
                        else
                        {
                            float _fChildGuard = 0;
                            if (dtFiltered.Rows[iRows]["ChildCare"].ToString() != "")
                            {
                                _fChildGuard = Convert.ToSingle(dtFiltered.Rows[iRows]["ChildCare"].ToString());
                            }

                            if (_fChildGuard > 0.0f)
                            {
                                string _ChildGuard = String.Format("{0:c0}", _fChildGuard);
                                lblChildGuard.Text = _ChildGuard;

                            }
                            else
                            {
                                imgChildGuard.Visible = true;
                                imgChildGuard.ImageUrl = "http://www.comparexpress.com/images/icon/X.png";
                            }
                        }

                        //Personal Liability
                        if (_providercompanyid == "34")
                        {
                            hlnkPL.Visible = true;
                            hlnkPL.ImageUrl = "http://www.comparexpress.com/images/icon/pdf.png";
                            hlnkPL.NavigateUrl = "http://www.comparexpress.com/policy_docs/ChinaTaiping/Coverage.pdf";
                            hlnkPL.Target = "_blank";
                        }
                        else
                        {
                            float _fPL = 0;
                            if (dtFiltered.Rows[iRows]["PersonalLiability"].ToString() != "")
                            {
                                _fPL = Convert.ToSingle(dtFiltered.Rows[iRows]["PersonalLiability"].ToString());
                            }

                            if (_fPL > 0.0f)
                            {
                                string _PL = String.Format("{0:c0}", _fPL);
                                lblPL.Text = _PL;
                            }
                            else
                            {
                                imgPL.Visible = true;
                                imgPL.ImageUrl = "http://www.comparexpress.com/images/icon/X.png";
                            }
                        }

                        //Loss Baggage & Personal Effects
                        if (_providercompanyid == "34")
                        {
                            hlnkLossBag.Visible = true;
                            hlnkLossBag.ImageUrl = "http://www.comparexpress.com/images/icon/pdf.png";
                            hlnkLossBag.NavigateUrl = "http://www.comparexpress.com/policy_docs/ChinaTaiping/Coverage.pdf";
                            hlnkLossBag.Target = "_blank";
                        }
                        else
                        {
                            float _fLossBaggage = 0;
                            if (dtFiltered.Rows[iRows]["BagPerEffect"].ToString() != "")
                            {
                                _fLossBaggage = Convert.ToSingle(dtFiltered.Rows[iRows]["BagPerEffect"].ToString());
                            }

                            if (_fLossBaggage > 0.0f)
                            {
                                string _LossBaggage = String.Format("{0:c0}", _fLossBaggage);
                                lblLossBag.Text = _LossBaggage;

                                if (_providercompanyid == "38")
                                {
                                    lblLossBag.Text = _LossBaggage + "<br/>($500 per article/laptop/mobile phone or PDA)";
                                }

                                if (_providercompanyid == "24")
                                {
                                    lblLossBag.Text = _LossBaggage + "<br/>$1,000 per item";
                                }
                            }
                            else
                            {
                                imgLossBag.Visible = true;
                                imgLossBag.ImageUrl = "http://www.comparexpress.com/images/icon/X.png";
                            }
                        }

                        //Overseas Baggage Delay
                        if (_providercompanyid == "34")
                        {
                            hlnkBagDelay.Visible = true;
                            hlnkBagDelay.ImageUrl = "http://www.comparexpress.com/images/icon/pdf.png";
                            hlnkBagDelay.NavigateUrl = "http://www.comparexpress.com/policy_docs/ChinaTaiping/Coverage.pdf";
                            hlnkBagDelay.Target = "_blank";
                        }
                        else
                        {
                            float _fOverseasBaggage = 0;
                            if (dtFiltered.Rows[iRows]["BagDelay"].ToString() != "")
                            {
                                _fOverseasBaggage = Convert.ToSingle(dtFiltered.Rows[iRows]["BagDelay"].ToString());
                            }

                            if (_fOverseasBaggage > 0.0f)
                            {
                                string _OverseasBaggage = String.Format("{0:c0}", _fOverseasBaggage) + "/" + dtFiltered.Rows[iRows]["Ninfo5"].ToString() + "-hour delay";
                                _OverseasBaggage += "<br/> max " + String.Format("{0:c0}", int.Parse(dtFiltered.Rows[iRows]["Ninfo6"].ToString()));
                                lblBagDelay.Text = _OverseasBaggage;

                                if (_providercompanyid == "38")
                                {
                                    lblBagDelay.Text = String.Format("{0:c0}", int.Parse(dtFiltered.Rows[iRows]["Ninfo6"].ToString()));
                                }
                            }
                            else
                            {
                                imgBagDelay.Visible = true;
                                imgBagDelay.ImageUrl = "http://www.comparexpress.com/images/icon/X.png";
                            }
                        }

                        //Trip Cancellation
                        if (_providercompanyid == "34")
                        {
                            hlnkTripCancel.Visible = true;
                            hlnkTripCancel.ImageUrl = "http://www.comparexpress.com/images/icon/pdf.png";
                            hlnkTripCancel.NavigateUrl = "http://www.comparexpress.com/policy_docs/ChinaTaiping/Coverage.pdf";
                            hlnkTripCancel.Target = "_blank";
                        }
                        else
                        {
                            float _fTripCancellation = 0;
                            if (dtFiltered.Rows[iRows]["DepositTripCancel"].ToString() != "")
                            {
                                _fTripCancellation = Convert.ToSingle(dtFiltered.Rows[iRows]["DepositTripCancel"].ToString());
                            }

                            if (_fTripCancellation > 0.0f)
                            {
                                string _TripCancellation = String.Format("{0:c0}", _fTripCancellation);
                                lblTripCancel.Text = _TripCancellation;

                            }
                            else
                            {
                                imgTripCancel.Visible = true;
                                imgTripCancel.ImageUrl = "http://www.comparexpress.com/images/icon/X.png";
                            }
                        }

                        //Trip Curtailment
                        if (_providercompanyid == "34")
                        {
                            hlnkTripCurtail.Visible = true;
                            hlnkTripCurtail.ImageUrl = "http://www.comparexpress.com/images/icon/pdf.png";
                            hlnkTripCurtail.NavigateUrl = "http://www.comparexpress.com/policy_docs/ChinaTaiping/Coverage.pdf";
                            hlnkTripCurtail.Target = "_blank";
                        }
                        else
                        {
                            float _fTripCurtailment = 0;
                            if (dtFiltered.Rows[iRows]["Curtailment"].ToString() != "")
                            {
                                _fTripCurtailment = Convert.ToSingle(dtFiltered.Rows[iRows]["Curtailment"].ToString());
                            }

                            if (_fTripCurtailment > 0.0f)
                            {
                                string _TripCurtailment = String.Format("{0:c0}", _fTripCurtailment);
                                lblTripCurtail.Text = _TripCurtailment;

                                if (_providercompanyid == "38")
                                {
                                   lblTripCurtail.Text = String.Format("{0:c0}", Convert.ToSingle(dtFiltered.Rows[iRows]["DepositTripCancel"].ToString()));
                                }

                            }
                            else
                            {
                                imgTripCurtail.Visible = true;
                                imgTripCurtail.ImageUrl = "http://www.comparexpress.com/images/icon/X.png";
                            }
                        }

                        //Overseas Travel Delay
                        if (_providercompanyid == "34")
                        {
                            hlnkTravelDelay.Visible = true;
                            hlnkTravelDelay.ImageUrl = "http://www.comparexpress.com/images/icon/pdf.png";
                            hlnkTravelDelay.NavigateUrl = "http://www.comparexpress.com/policy_docs/ChinaTaiping/Coverage.pdf";
                            hlnkTravelDelay.Target = "_blank";
                        }
                        else
                        {
                            float _fTravelDelay = 0;
                            if (dtFiltered.Rows[iRows]["TravelDelay"].ToString() != "")
                            {
                                _fTravelDelay = Convert.ToSingle(dtFiltered.Rows[iRows]["TravelDelay"].ToString());
                            }

                            if (_fTravelDelay > 0.0f)
                            {

                                if (_providercompanyid == "38")
                                {
                                    string _TravelDelay = "$1,000 <br/>($100 per 6 hrs *)<br/>* $50 per 6 hrs for Jetstar and Tiger";
                                    lblTravelDelay.Text = _TravelDelay;

                                }
                                else
                                {
                                    string _TravelDelay = String.Format("{0:c0}", _fTravelDelay) + "/" + dtFiltered.Rows[iRows]["Ninfo7"].ToString() + "-hour delay";
                                    _TravelDelay += "<br/> max " + String.Format("{0:c0}", int.Parse(dtFiltered.Rows[iRows]["Ninfo8"].ToString()));
                                    lblTravelDelay.Text = _TravelDelay;
                                }

                            }
                            else
                            {
                                imgTravelDelay.Visible = true;
                                imgTravelDelay.ImageUrl = "http://www.comparexpress.com/images/icon/X.png";
                            }
                        }

                        //Missed Travel Connection
                        if (_providercompanyid == "34")
                        {
                            hlnkTravelConn.Visible = true;
                            hlnkTravelConn.ImageUrl = "http://www.comparexpress.com/images/icon/pdf.png";
                            hlnkTravelConn.NavigateUrl = "http://www.comparexpress.com/policy_docs/ChinaTaiping/Coverage.pdf";
                            hlnkTravelConn.Target = "_blank";
                        }
                        else
                        {
                            float _fTravelConnection = 0;
                            if (dtFiltered.Rows[iRows]["MissTravelConnection"].ToString() != "")
                            {
                                _fTravelConnection = Convert.ToSingle(dtFiltered.Rows[iRows]["MissTravelConnection"].ToString());
                            }

                            if (_fTravelConnection > 0.0f)
                            {
                                string _TravelConnection = String.Format("{0:c0}", _fTravelConnection);
                                lblTravelConn.Text = _TravelConnection;

                            }
                            else
                            {
                                imgTravelConn.Visible = true;
                                imgTravelConn.ImageUrl = "http://www.comparexpress.com/images/icon/X.png";
                            }
                        }

                        //Travel Overbooked
                        if (_providercompanyid == "34")
                        {
                            hlnkTravelOverbook.Visible = true;
                            hlnkTravelOverbook.ImageUrl = "http://www.comparexpress.com/images/icon/pdf.png";
                            hlnkTravelOverbook.NavigateUrl = "http://www.comparexpress.com/policy_docs/ChinaTaiping/Coverage.pdf";
                            hlnkTravelOverbook.Target = "_blank";
                        }
                        else
                        {
                            float _fTravelOverbooked = 0;
                            if (dtFiltered.Rows[iRows]["TravelOverBook"].ToString() != "")
                            {
                                _fTravelOverbooked = Convert.ToSingle(dtFiltered.Rows[iRows]["TravelOverBook"].ToString());
                            }

                            if (_fTravelOverbooked > 0.0f)
                            {
                                string _TravelOverbooked = String.Format("{0:c0}", _fTravelOverbooked);
                                lblTravelOverbook.Text = _TravelOverbooked;

                            }
                            else
                            {
                                imgTravelOverbook.Visible = true;
                                imgTravelOverbook.ImageUrl = "http://www.comparexpress.com/images/icon/X.png";
                            }
                        }

                        //Loss of Personal Money
                        if (_providercompanyid == "34")
                        {
                            hlnkMoney.Visible = true;
                            hlnkMoney.ImageUrl = "http://www.comparexpress.com/images/icon/pdf.png";
                            hlnkMoney.NavigateUrl = "http://www.comparexpress.com/policy_docs/ChinaTaiping/Coverage.pdf";
                            hlnkMoney.Target = "_blank";
                        }
                        else
                        {
                            float _fLossMoney = 0;
                            if (dtFiltered.Rows[iRows]["PersonalMoney"].ToString() != "")
                            {
                                _fLossMoney = Convert.ToSingle(dtFiltered.Rows[iRows]["PersonalMoney"].ToString());
                            }

                            if (_fLossMoney > 0.0f)
                            {
                                string _LossMoney = String.Format("{0:c0}", _fLossMoney);
                                lblMoney.Text = _LossMoney;

                            }
                            else
                            {
                                imgMoney.Visible = true;
                                imgMoney.ImageUrl = "http://www.comparexpress.com/images/icon/X.png";
                            }
                        }

                        //Loss of Travel Documents
                        if (_providercompanyid == "34")
                        {
                            hlnkTravelDoc.Visible = true;
                            hlnkTravelDoc.ImageUrl = "http://www.comparexpress.com/images/icon/pdf.png";
                            hlnkTravelDoc.NavigateUrl = "http://www.comparexpress.com/policy_docs/ChinaTaiping/Coverage.pdf";
                            hlnkTravelDoc.Target = "_blank";
                        }
                        else
                        {
                            float _fLossDocument = 0;
                            if (dtFiltered.Rows[iRows]["TravelDoc"].ToString() != "")
                            {
                                _fLossDocument = Convert.ToSingle(dtFiltered.Rows[iRows]["TravelDoc"].ToString());
                            }

                            if (_fLossDocument > 0.0f)
                            {
                                string _LossDocument = String.Format("{0:c0}", _fLossDocument);
                                lblTravelDoc.Text = _LossDocument;

                            }
                            else
                            {
                                imgTravelDoc.Visible = true;
                                imgTravelDoc.ImageUrl = "http://www.comparexpress.com/images/icon/X.png";
                            }
                        }

                        //Closure of Travel Agency
                        if (_providercompanyid == "34")
                        {
                            hlnkTravelAgency.Visible = true;
                            hlnkTravelAgency.ImageUrl = "http://www.comparexpress.com/images/icon/pdf.png";
                            hlnkTravelAgency.NavigateUrl = "http://www.comparexpress.com/policy_docs/ChinaTaiping/Coverage.pdf";
                            hlnkTravelAgency.Target = "_blank";
                        }
                        else
                        {
                            float _fClosure = 0;
                            if (dtFiltered.Rows[iRows]["Info3"].ToString() != "")
                            {
                                _fClosure = Convert.ToSingle(dtFiltered.Rows[iRows]["Info3"].ToString());
                            }

                            if (_fClosure > 0.0f)
                            {
                                string _Closure = String.Format("{0:c0}", _fClosure);
                                lblTravelAgency.Text = _Closure;

                            }
                            else
                            {
                                imgTravelAgency.Visible = true;
                                imgTravelAgency.ImageUrl = "http://www.comparexpress.com/images/icon/X.png";
                            }
                        }

                        //Home Contents
                        if (_providercompanyid == "34")
                        {
                            hlnkHomeProtect.Visible = true;
                            hlnkHomeProtect.ImageUrl = "http://www.comparexpress.com/images/icon/pdf.png";
                            hlnkHomeProtect.NavigateUrl = "http://www.comparexpress.com/policy_docs/ChinaTaiping/Coverage.pdf";
                            hlnkHomeProtect.Target = "_blank";
                        }
                        else
                        {
                            float _fHomeContent = 0;
                            if (dtFiltered.Rows[iRows]["FBHCP"].ToString() != "")
                            {
                                _fHomeContent = Convert.ToSingle(dtFiltered.Rows[iRows]["FBHCP"].ToString());
                            }

                            if (_fHomeContent > 0.0f)
                            {
                                string _HomeContent = String.Format("{0:c0}", _fHomeContent);
                                lblHomeProtect.Text = _HomeContent;

                                if (_providercompanyid == "23")
                                {
                                    if (Session["TripType"].ToString() == "A")
                                    {
                                        lblHomeProtect.Text = "Optional";
                                    }
                                }
                            }
                            else
                            {
                                imgHomeProtect.Visible = true;
                                imgHomeProtect.ImageUrl = "http://www.comparexpress.com/images/icon/X.png";
                            }
                        }

                        //Rental Vehicle
                        if (_providercompanyid == "34")
                        {
                            hlnkCarRent.Visible = true;
                            hlnkCarRent.ImageUrl = "http://www.comparexpress.com/images/icon/pdf.png";
                            hlnkCarRent.NavigateUrl = "http://www.comparexpress.com/policy_docs/ChinaTaiping/Coverage.pdf";
                            hlnkCarRent.Target = "_blank";
                        }
                        else
                        {
                            float _fRentalVehicle = 0;
                            if (dtFiltered.Rows[iRows]["ACRR"].ToString() != "")
                            {
                                _fRentalVehicle = Convert.ToSingle(dtFiltered.Rows[iRows]["ACRR"].ToString());
                            }

                            if (_fRentalVehicle > 0.0f)
                            {
                                string _RentalVehicle = String.Format("{0:c0}", _fRentalVehicle);
                                lblCarRent.Text = _RentalVehicle;

                            }
                            else
                            {
                                imgCarRent.Visible = true;
                                imgCarRent.ImageUrl = "http://www.comparexpress.com/images/icon/X.png";
                            }
                        }

                        //Hijack
                        if (_providercompanyid == "34")
                        {
                            hlnkHijack.Visible = true;
                            hlnkHijack.ImageUrl = "http://www.comparexpress.com/images/icon/pdf.png";
                            hlnkHijack.NavigateUrl = "http://www.comparexpress.com/policy_docs/ChinaTaiping/Coverage.pdf";
                            hlnkHijack.Target = "_blank";
                        }
                        else
                        {
                            float _fHijack = 0;
                            if (dtFiltered.Rows[iRows]["Terrorism"].ToString() != "")
                            {
                                _fHijack = Convert.ToSingle(dtFiltered.Rows[iRows]["Terrorism"].ToString());
                            }

                            if (_fHijack > 0.0f)
                            {
                                string _Hijack = String.Format("{0:c0}", _fHijack) + "/" + dtFiltered.Rows[iRows]["Info1"].ToString() + "-hour";
                                _Hijack += "<br/> max " + String.Format("{0:c0}", int.Parse(dtFiltered.Rows[iRows]["Info2"].ToString()));
                                lblHijack.Text = _Hijack;

                            }
                            else
                            {
                                imgHijack.Visible = true;
                                imgHijack.ImageUrl = "http://www.comparexpress.com/images/icon/X.png";
                            }
                        }

                        //Kidnap / Hostage
                        if (_providercompanyid == "34")
                        {
                            hlnkKidnap.Visible = true;
                            hlnkKidnap.ImageUrl = "http://www.comparexpress.com/images/icon/pdf.png";
                            hlnkKidnap.NavigateUrl = "http://www.comparexpress.com/policy_docs/ChinaTaiping/Coverage.pdf";
                            hlnkKidnap.Target = "_blank";
                        }
                        else
                        {
                            float _fKidnap = 0;
                            if (dtFiltered.Rows[iRows]["KidnapHostage"].ToString() != "")
                            {
                                _fKidnap = Convert.ToSingle(dtFiltered.Rows[iRows]["KidnapHostage"].ToString());
                            }

                            if (_fKidnap > 0.0f)
                            {
                                string _Kidnap = String.Format("{0:c0}", _fKidnap);
                                lblKidnap.Text = _Kidnap;

                            }
                            else
                            {
                                imgKidnap.Visible = true;
                                imgKidnap.ImageUrl = "http://www.comparexpress.com/images/icon/X.png";
                            }
                        }

                        //Emergency Tel Charges
                        if (_providercompanyid == "34")
                        {
                            hlnkPhoneCharge.Visible = true;
                            hlnkPhoneCharge.ImageUrl = "http://www.comparexpress.com/images/icon/pdf.png";
                            hlnkPhoneCharge.NavigateUrl = "http://www.comparexpress.com/policy_docs/ChinaTaiping/Coverage.pdf";
                            hlnkPhoneCharge.Target = "_blank";
                        }
                        else
                        {
                            float _fTelCharge = 0;
                            if (dtFiltered.Rows[iRows]["EmTelCharge"].ToString() != "")
                            {
                                _fTelCharge = Convert.ToSingle(dtFiltered.Rows[iRows]["EmTelCharge"].ToString());
                            }

                            if (dtFiltered.Rows[iRows]["Info6"].ToString() != "" && dtFiltered.Rows[iRows]["Info6"].ToString() == "True")
                            {
                                lblPhoneCharge.Text = "<font color='red'>*actual cost</font>";
                            }
                            else
                            {

                                if (_fTelCharge > 0.0f)
                                {
                                    string _TelCharge = String.Format("{0:c0}", _fTelCharge);
                                    lblPhoneCharge.Text = _TelCharge;

                                }
                                else
                                {
                                    imgPhoneCharge.Visible = true;
                                    imgPhoneCharge.ImageUrl = "http://www.comparexpress.com/images/icon/X.png";
                                }
                            }
                        }

                        //policy
                        string _policyId = dtFiltered.Rows[iRows]["NInfo1"].ToString();

                        ProviderPolicyDocument _policydoc = new ProviderPolicyDocument();
                        ProviderPolicyDocumentDB _policydocdb = new ProviderPolicyDocumentDB();

                        _policydoc = _policydocdb.GetProviderPolicyDocument(Convert.ToInt64(_policyId));

                        string docurl = "http://www.comparexpress.com" + _policydoc.UploadPath.Remove(0,1);
                        //HyperLink _lnkTest = new HyperLink();
                        //_lnkTest.NavigateUrl = "http://www.comparexpress.com" + docurl.Remove(0,1);

                        hlnkPolicyDoc.ImageUrl = "http://www.comparexpress.com/images/icon/pdf.png";
                        hlnkPolicyDoc.NavigateUrl = docurl; //_lnkTest.ResolveClientUrl(docurl);
                        hlnkPolicyDoc.Target = "_blank";


                    }

                }
            }
            else
            {
                Response.Redirect("travel-result.aspx");
            }
        }
        else
        {
            Response.Redirect("travel-result.aspx");
        }

    }

    protected void imgEmailQuote_Click(object sender, ImageClickEventArgs e)
    {
        if (Session[General.TAEmail] != null)
        {
            string _emailList = "", _title = "";
            System.Text.StringBuilder _message = new System.Text.StringBuilder();
            _emailList = Session[General.TAEmail].ToString();
            //_emailList += ";team@comparexpress.com";
            //string _currentDomainUrl = "http://" + HttpContext.Current.Request.Url.Host.ToString() + "/";
            string _currentDomainUrl = ""; // "http://www.comparexpress.com/";
            _title = "";

            _title = "CompareXpress.com (Ref No : " + lblRefNo.Text + ")";

            _message.Append("<table cellpadding='0' cellspacing='0' border='0' width='240' style='font-family:Arial, Helvetica, sans-serif; font-size:12px; margin:0 auto;'>");
            _message.Append("<tr><td style='border-bottom:1px solid #ccc;' align='center'><img src='http://www.comparexpress.com/images/nav/logo_comparexpress.png' alt='' height='78' /><br/><br/>");
            _message.Append("Thank you for choosing CompareXpress.com <br/><strong>Here is your Quote Details </strong><br /><br/></td></tr>");

            _message.Append("<tr><td style='border-bottom:1px solid #ccc;'><br /><table cellspacing='0' cellpadding='2' width='100%' border='0'>");

            _message.Append("<tr><td valign='top'>Quote Ref Number</td>");
            _message.Append("<td valign='top'><strong><u>" + lblRefNo.Text + "</u></strong></td></tr>");

            _message.Append("<tr><td valign='top'>Trip Type</td>");
            _message.Append("<td valign='top'><strong>" + lblTripType.Text + "</strong></td></tr>");

            _message.Append("<tr><td valign='top'>Type of Policy</td>");
            _message.Append("<td valign='top'><strong>" + lblPolicy.Text + "</strong></td></tr>");

            _message.Append("<tr><td valign='top'>Coverage</td>");
            _message.Append("<td valign='top'><strong>" + lblCoverage.Text + "</strong></td></tr>");

            _message.Append("<tr><td valign='top'>Destination</td>");
            _message.Append("<td valign='top'><strong>" + lblDestination.Text + "</strong></td></tr>");

            _message.Append("<tr><td valign='top'>Travel Date</td>");
            _message.Append("<td valign='top'><strong>" + lblTravelDate.Text + "</strong></td></tr>");

            _message.Append("<tr><td valign='top'>No. of Traveller/s</td>");
            _message.Append("<td valign='top'><strong>" + lblTravellers.Text + "</strong></td></tr>");

            _message.Append("<tr><td valign='top'>Quote Date</td>");
            _message.Append("<td valign='top'><strong>" + lblQuoteDate.Text + "</strong></td></tr>");

            _message.Append("</table><br /></td></tr><tr><td width='300'><br />");

            _message.Append("<table width='100%' border='0' cellpadding='5' cellspacing='0'  class='table_details'>");

            _message.Append("<tr><td width='45%'></td>");
            _message.Append("<td width='55%' align='center' style='background:#e0e0e0; border-bottom:white 1px dashed;'>");
            _message.Append("<img src='" + imgInsurer.ImageUrl + "'  width='120px' /></td></tr>");

            _message.Append("<tr><td><strong>Insurer</strong></td>");
            _message.Append("<td align='center' style='background:#d5d5d5; color:black;' ><strong>" + lblInsurer.Text + "</strong></td></tr>");

            _message.Append("<tr><td></td>");
            _message.Append("<td align='center' style='background:#d5d5d5;'>" + lblPackage.Text + "</td></tr>");

            _message.Append("<tr><td align='left' style='background:#d5d5d5' ><strong>Annual Premium</strong></td>");
            _message.Append("<td align='center' style='background:#d5d5d5; color:black; font-size:16px;'><strong>" + lblPrice.Text + "</strong></td></tr>");

            _message.Append("<tr><td style='border-bottom:1px solid #ccc;'><strong>Personal Accident (adult)</strong></td>");
            _message.Append("<td align='center' style='background:#d5d5d5' >");

            if (imgPAadult.Visible)
                _message.Append("<img src='" + imgPAadult.ImageUrl + "' /></td></tr>");
            else
                _message.Append(lblPAadult.Text + "</td></tr>");

            _message.Append("<tr><td style='border-bottom:1px solid #ccc;'><strong>Personal Accident (senior)</strong></td>");
            _message.Append("<td align='center' style='background:#d5d5d5' >");

            if (imgPAsenior.Visible)
                _message.Append("<img src='" + imgPAsenior.ImageUrl + "' /></td></tr>");
            else
                _message.Append(lblPAsenior.Text + "</td></tr>");

            _message.Append("<tr><td style='border-bottom:1px solid #ccc;'><strong>Double Indemnity (adult)</strong></td>");
            _message.Append("<td align='center' style='background:#d5d5d5;'>");

            if (imgDIadult.Visible)
                _message.Append("<img src='" + imgDIadult.ImageUrl + "' /></td></tr>");
            else
                _message.Append(lblDIadult.Text + "</td></tr>");

            _message.Append("<tr><td style='border-bottom:1px solid #ccc;'><strong>Double Indemnity (senior)</strong></td>");
            _message.Append("<td align='center' style='background:#d5d5d5;'>");

            if (imgDIsenior.Visible)
                _message.Append("<img src='" + imgDIsenior.ImageUrl + "' /></td></tr>");
            else
                _message.Append(lblDIsenior.Text + "</td></tr>");

            _message.Append("<tr><td style='border-bottom:1px solid #ccc;'><strong>Medical Expense (adult)</strong></td>");
            _message.Append("<td align='center' style='background:#d5d5d5;'>");

            if (imgMedExpadult.Visible)
                _message.Append("<img src='" + imgMedExpadult.ImageUrl + "' /></td></tr>");
            else
                _message.Append(lblMedExpadult.Text + "</td></tr>");

            _message.Append("<tr><td style='border-bottom:1px solid #ccc;'><strong>Medical Expense (senior)</strong></td>");
            _message.Append("<td align='center' style='background:#d5d5d5;'>");

            if (imgMedExpsenior.Visible)
                _message.Append("<img src='" + imgMedExpsenior.ImageUrl + "' /></td></tr>");
            else
                _message.Append(lblMedExpsenior.Text + "</td></tr>");

            _message.Append("<tr><td style='border-bottom:1px solid #ccc;'><strong>Emergency Medical Evacuation</strong></td>");
            _message.Append("<td align='center' style='background:#d5d5d5;'>");

            if (imgEmMedEvac.Visible)
                _message.Append("<img src='" + imgEmMedEvac.ImageUrl + "' /></td></tr>");
            else
                _message.Append(lblEmMedEvac.Text + "</td></tr>");

            _message.Append("<tr><td style='border-bottom:1px solid #ccc;'><strong>Repatriation & Funeral Expenses</strong></td>");
            _message.Append("<td align='center' style='background:#d5d5d5;'>");

            if (imgRepatriation.Visible)
                _message.Append("<img src='" + imgRepatriation.ImageUrl + "' /></td></tr>");
            else
                _message.Append(lblRepatriation.Text + "</td></tr>");

            _message.Append("<tr><td style='border-bottom:1px solid #ccc;'><strong>Hospital Income</strong></td>");
            _message.Append("<td align='center' style='background:#d5d5d5;'>");

            if (imgHospitalInc.Visible)
                _message.Append("<img src='" + imgHospitalInc.ImageUrl + "' /></td></tr>");
            else
                _message.Append(lblHospitalInc.Text + "</td></tr>");

            _message.Append("<tr><td style='border-bottom:1px solid #ccc;'><strong>Pregnancy-related Illness</strong></td>");
            _message.Append("<td align='center' style='background:#d5d5d5;'>");

            if (imgPregnancy.Visible)
                _message.Append("<img src='" + imgPregnancy.ImageUrl + "' /></td></tr>");
            else
                _message.Append(lblPregnancy.Text + "</td></tr>");

            _message.Append("<tr><td style='border-bottom:1px solid #ccc;'><strong>Overseas Compassionate Visit</strong></td>");
            _message.Append("<td align='center' style='background:#d5d5d5;'>");

            if (imgOCV.Visible)
                _message.Append("<img src='" + imgOCV.ImageUrl + "' /></td></tr>");
            else
                _message.Append(lblOCV.Text + "</td></tr>");

            _message.Append("<tr><td style='border-bottom:1px solid #ccc;'><strong>Child Guard</strong></td>");
            _message.Append("<td align='center' style='background:#d5d5d5;'>");

            if (imgChildGuard.Visible)
                _message.Append("<img src='" + imgChildGuard.ImageUrl + "' /></td></tr>");
            else
                _message.Append(lblChildGuard.Text + "</td></tr>");

            _message.Append("<tr><td style='border-bottom:1px solid #ccc;'><strong>Personal Liability</strong></td>");
            _message.Append("<td align='center' style='background:#d5d5d5;'>");

            if (imgPL.Visible)
                _message.Append("<img src='" + imgPL.ImageUrl + "' /></td></tr>");
            else
                _message.Append(lblPL.Text + "</td></tr>");

            _message.Append("<tr><td style='border-bottom:1px solid #ccc;'><strong>Loss Baggage & Personal Effects</strong></td>");
            _message.Append("<td align='center' style='background:#d5d5d5;'>");

            if (imgLossBag.Visible)
                _message.Append("<img src='" + imgLossBag.ImageUrl + "' /></td></tr>");
            else
                _message.Append(lblLossBag.Text + "</td></tr>");

            _message.Append("<tr><td style='border-bottom:1px solid #ccc;'><strong>Overseas Baggage Delay</strong></td>");
            _message.Append("<td align='center' style='background:#d5d5d5;'>");

            if (imgBagDelay.Visible)
                _message.Append("<img src='" + imgBagDelay.ImageUrl + "' /></td></tr>");
            else
                _message.Append(lblBagDelay.Text + "</td></tr>");

            _message.Append("<tr><td style='border-bottom:1px solid #ccc;'><strong>Trip Cancellation</strong></td>");
            _message.Append("<td align='center' style='background:#d5d5d5;'>");

            if (imgTripCancel.Visible)
                _message.Append("<img src='" + imgTripCancel.ImageUrl + "' /></td></tr>");
            else
                _message.Append(lblTripCancel.Text + "</td></tr>");

            _message.Append("<tr><td style='border-bottom:1px solid #ccc;'><strong>Trip Curtailment</strong></td>");
            _message.Append("<td align='center' style='background:#d5d5d5;'>");

            if (imgTripCurtail.Visible)
                _message.Append("<img src='" + imgTripCurtail.ImageUrl + "' /></td></tr>");
            else
                _message.Append(lblTripCurtail.Text + "</td></tr>");

            _message.Append("<tr><td style='border-bottom:1px solid #ccc;'><strong>Overseas Travel Delay</strong></td>");
            _message.Append("<td align='center' style='background:#d5d5d5;'>");

            if (imgTravelDelay.Visible)
                _message.Append("<img src='" + imgTravelDelay.ImageUrl + "' /></td></tr>");
            else
                _message.Append(lblTravelDelay.Text + "</td></tr>");

            _message.Append("<tr><td style='border-bottom:1px solid #ccc;'><strong>Missed Travel Connection</strong></td>");
            _message.Append("<td align='center' style='background:#d5d5d5;'>");

            if (imgTravelConn.Visible)
                _message.Append("<img src='" + imgTravelConn.ImageUrl + "' /></td></tr>");
            else
                _message.Append(lblTravelConn.Text + "</td></tr>");

            _message.Append("<tr><td style='border-bottom:1px solid #ccc;'><strong>Travel Overbooked</strong></td>");
            _message.Append("<td align='center' style='background:#d5d5d5;'>");

            if (imgTravelOverbook.Visible)
                _message.Append("<img src='" + imgTravelOverbook.ImageUrl + "' /></td></tr>");
            else
                _message.Append(lblTravelOverbook.Text + "</td></tr>");

            _message.Append("<tr><td style='border-bottom:1px solid #ccc;'><strong>Loss of Personal Money</strong></td>");
            _message.Append("<td align='center' style='background:#d5d5d5;'>");

            if (imgMoney.Visible)
                _message.Append("<img src='" + imgMoney.ImageUrl + "' /></td></tr>");
            else
                _message.Append(lblMoney.Text + "</td></tr>");

            _message.Append("<tr><td style='border-bottom:1px solid #ccc;'><strong>Loss of Travel Documents</strong></td>");
            _message.Append("<td align='center' style='background:#d5d5d5;'>");

            if (imgTravelDoc.Visible)
                _message.Append("<img src='" + imgTravelDoc.ImageUrl + "' /></td></tr>");
            else
                _message.Append(lblTravelDoc.Text + "</td></tr>");

            _message.Append("<tr><td style='border-bottom:1px solid #ccc;'><strong>Closure of Travel Agency</strong></td>");
            _message.Append("<td align='center' style='background:#d5d5d5;'>");

            if (imgTravelAgency.Visible)
                _message.Append("<img src='" + imgTravelAgency.ImageUrl + "' /></td></tr>");
            else
                _message.Append(lblTravelAgency.Text + "</td></tr>");

            _message.Append("<tr><td style='border-bottom:1px solid #ccc;'><strong>Home Contents Protection</strong></td>");
            _message.Append("<td align='center' style='background:#d5d5d5;'>");

            if (imgHomeProtect.Visible)
                _message.Append("<img src='" + imgHomeProtect.ImageUrl + "' /></td></tr>");
            else
                _message.Append(lblHomeProtect.Text + "</td></tr>");

            _message.Append("<tr><td style='border-bottom:1px solid #ccc;'><strong>Rental Vehicle Excess</strong></td>");
            _message.Append("<td align='center' style='background:#d5d5d5;'>");

            if (imgCarRent.Visible)
                _message.Append("<img src='" + imgCarRent.ImageUrl + "' /></td></tr>");
            else
                _message.Append(lblCarRent.Text + "</td></tr>");

            _message.Append("<tr><td style='border-bottom:1px solid #ccc;'><strong>Hijack</strong></td>");
            _message.Append("<td align='center' style='background:#d5d5d5;'>");

            if (imgHijack.Visible)
                _message.Append("<img src='" + imgHijack.ImageUrl + "' /></td></tr>");
            else
                _message.Append(lblHijack.Text + "</td></tr>");

            _message.Append("<tr><td style='border-bottom:1px solid #ccc;'><strong>Kidnap/Hostage</strong></td>");
            _message.Append("<td align='center' style='background:#d5d5d5;'>");

            if (imgKidnap.Visible)
                _message.Append("<img src='" + imgKidnap.ImageUrl + "' /></td></tr>");
            else
                _message.Append(lblKidnap.Text + "</td></tr>");

            _message.Append("<tr><td style='border-bottom:1px solid #ccc;'><strong>Emergency Telephone Charges</strong></td>");
            _message.Append("<td align='center' style='background:#d5d5d5;'>");

            if (imgPhoneCharge.Visible)
                _message.Append("<img src='" + imgPhoneCharge.ImageUrl + "' /></td></tr>");
            else
                _message.Append(lblPhoneCharge.Text + "</td></tr>");

            string docurl = hlnkPolicyDoc.NavigateUrl;
            string viewpolicywordings = "<a href='" + docurl + "' ><img src='http://www.comparexpress.com/images/icon/pdf.png'  alt='policy wordings' width='23' alt='NA' border='0'/></a>";

            _message.Append("<tr><td style='border-bottom:1px solid #ccc;'><strong>View Policy Wordings</strong></td>");
            _message.Append("<td align='center' style='background:#d5d5d5;'>" + viewpolicywordings + "</td></tr>");

            _message.Append("</table><br /><br />");
            //_message.Append("<a href='tel:022688222'><img src='http://www.gluaygluay.com/images/banners/hotline_en.png' alt='Call Us at 02 268 8222' width='240' border='0' /></a>");
            //_message.Append("<br /><br /><br />");

            _message.Append("<strong>Important Notes</strong><br />");
            _message.Append("• The amounts listed in the benefits table are the maximum coverage payable for each benefit.<br />");
            _message.Append("• Coverage intended for overseas traveling and not in Singapore. Insured person must be Singaporean or Singapore Permanent Resident only. <br />");
            _message.Append("• Information displayed here is a summary. Please read the actual policy wordings for details of coverage. <br />");
            _message.Append("</td></tr><tr><td id='email_footer'></td>");
            _message.Append("</tr></table><br /><br /><hr />This Quote is subject to the insurer's final confirmation and coverage is only effective when the insurer has accepted the risk.<br /><br />");
            _message.Append("<i>This is a computer-generated email. Please do not reply to this email.</i><hr />");

            MyMailManager.SendCRMMessage(_emailList, _title, _message.ToString());
            Response.Redirect("../email-confirm.aspx?type=email&resultid=" + lblTAResultID.Text);
        }
        else
            Response.Redirect("travel-quote.aspx");
    }
}
